package com.cssy.xxkj.logic.dao.impl;

import com.cssy.xxkj.logic.dao.LogicPurchaseWareDAO;
import com.cssy.xxkj.logic.entity.LogicPurchaseWareDO;
import com.cssy.xxkj.logic.entity.LogicSalesDO;
import com.cssy.xxkj.logic.entity.vo.LogicPurchaseWareSumVO;
import com.plat.helper.SearchConditions;

import java.util.List;
import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

/**
 * 数据访问对象实现类
 * @since 2014-09-19
 */
public class LogicPurchaseWareDAOImpl extends SqlMapClientDaoSupport implements LogicPurchaseWareDAO {

    /**
     * 插入数据
     * @param logicPurchaseWareDO
     * @return 插入数据的主键
     */
    public String insertLogicPurchaseWareDO(LogicPurchaseWareDO logicPurchaseWareDO) throws DataAccessException {
        Object id = getSqlMapClientTemplate().insert("LogicPurchaseWare.insert", logicPurchaseWareDO);
        return (String) id;
    }

    /**
     * 统计记录数
     * @param logicPurchaseWareDO
     * @return 查出的记录数
     */
    public Integer countLogicPurchaseWareDOByExample(LogicPurchaseWareDO logicPurchaseWareDO) throws DataAccessException {
        Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicPurchaseWare.countByDOExample", logicPurchaseWareDO);
        return count;
    }

    /**
     * 更新记录
     * @param logicPurchaseWareDO
     * @return 受影响的行数
     */
    public Integer updateLogicPurchaseWareDO(LogicPurchaseWareDO logicPurchaseWareDO) throws DataAccessException {
        int result = getSqlMapClientTemplate().update("LogicPurchaseWare.update", logicPurchaseWareDO);
        return result;
    }

    /**
     * 获取对象列表
     * @param logicPurchaseWareDO
     * @return 对象列表
     */
    @SuppressWarnings("unchecked")
    public List<LogicPurchaseWareDO> findListByExample(LogicPurchaseWareDO logicPurchaseWareDO) throws DataAccessException {
        List<LogicPurchaseWareDO> list = getSqlMapClientTemplate().queryForList("LogicPurchaseWare.findListByDO", logicPurchaseWareDO);
        return list;
    }

    /**
     * 根据主键获取logicPurchaseWareDO
     * @param id
     * @return logicPurchaseWareDO
     */
    public LogicPurchaseWareDO findLogicPurchaseWareDOByPrimaryKey(String id) throws DataAccessException {
        LogicPurchaseWareDO logicPurchaseWareDO = (LogicPurchaseWareDO) getSqlMapClientTemplate().queryForObject("LogicPurchaseWare.findByPrimaryKey", id);
        return logicPurchaseWareDO;
    }

    /**
     * 删除记录
     * @param id
     * @return 受影响的行数
     */
    public Integer deleteLogicPurchaseWareDOByPrimaryKey(String id) throws DataAccessException {
        Integer rows = (Integer) getSqlMapClientTemplate().delete("LogicPurchaseWare.deleteByPrimaryKey", id);
        return rows;
    }

	@Override
	public List<LogicPurchaseWareDO> find(SearchConditions scs)
			throws DataAccessException {
		List<LogicPurchaseWareDO> list = getSqlMapClientTemplate().queryForList("LogicPurchaseWare_ex.find", scs);
        return list;
	}

	@Override
	public Integer count(SearchConditions scs) throws DataAccessException {
		Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicPurchaseWare_ex.count", scs);
        return count;
	}

	@Override
	public Integer deleteBizRemoved(String id) throws DataAccessException {
		Integer count = (Integer) getSqlMapClientTemplate().update("LogicPurchaseWare_ex.deleteBizRemoved", id);
        return count;
	}
	
}